<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="java.util.*,java.sql.*"
    %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./css/report.css" type="text/css"> 
<script type="text/javascript">

</script>
<% 
request.setCharacterEncoding("UTF-8"); 
response.setContentType("text/html;charset=UTF-8");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();

String userId = request.getParameter("user_id");
Statement stmt;
ResultSet rs;

Connection con=java.sql.DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=PZSYYDB","performance","performance");

%>

<title>
<%=request.getParameter("title") %>

</title>
</head>
<body>
<div>报表: <%=request.getParameter("title") %></div>
<br>
<div id="kaohe">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select id="year">
	<option value="2012">2012</option>
	<option value="2013">2013</option>
	<option value="2014">2014</option>
	<option value="2015">2015</option>
	<option value="2016">2016</option>
	<option value="2017">2017</option>
</select>年
<select id="month">
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	<option value="5">5</option>
	<option value="6">6</option>
	<option value="7">7</option>
	<option value="8">8</option>
	<option value="9">9</option>
	<option value="10">10</option>
	<option value="11">11</option>
	<option value="12">12</option>
</select>月
&nbsp;&nbsp;&nbsp;查看科室:<select>
	<option value="all">-全部-</option>
	<%
	stmt = con.createStatement();
	rs=stmt.executeQuery("select d.id,td.name+'-'+d.name from "+
	" t_sys_users_vs_department as uvd left join t_sys_stat_department as d on uvd.organization_id = d.id"+
	" left join DICT_DUTY_TYPE as td on td.id = d.duty_id"+
	" where code = '"+userId+"'");
	while(rs.next()){
		%><option value="<%=rs.getInt(1)%>"><%=rs.getString(2)%></option>	
		<%
	}
	rs.close();
	stmt.close();
	
	%>
</select>
&nbsp;&nbsp;&nbsp;
<input type="button" onclick="return submitFm();" value="查询"/>
</div>

<table id="report_table">
<thead>
<tr>
<td>id</td>
<td>function</td>
<td>function-detail</td>
</tr>
</thead>
<tbody>

<%
stmt=con.createStatement();
rs=stmt.executeQuery("select * from APP_FUNCTION");
int rowNumber = 0;
while(rs.next()){
	rowNumber++;
	%><tr
	<% 
	if(rowNumber%2 == 0){
		%> class="ds" <%
	}else{
		%> class="ss" <%
	}
	%>
	
	><td class="t1">
	<%=rs.getInt(1) %>
	</td>
	<td class="t2">
	<%=rs.getString(2) %>
	</td>
	<td class="t3">
	<%=rs.getString(3) %>
	</td></tr><%
}
rs.close();
stmt.close();
%>

</tbody>
<tfoot></tfoot>
</table>
<form id="searchForm" method="post" action="./BasicReport.jsp">
	<input type="hidden" name="title" value="<%=request.getParameter("title") %>"/>
	<input type="hidden" name="year"/>
	<input type="hidden" name="month"/>
	<input type="hidden" name="user_id" value="<%=userId%>"/>
	<input type="hidden" name="ks_name"/>
	<input type="hidden" name="ks_id"/>
</form>
<script type="text/javascript">
	var dt = new Date();
	
	window.onload = initData();
	
	function initData(){
		try{
			var y = <%=request.getParameter("year")%>;
			var m = <%=request.getParameter("month")%>;
			
			if(y == null && m == null){
				if(dt.getMonth() == 1){
					document.getElementById("year").options[dt.getYear()+1900-2013].selected = true;
					document.getElementById("month").options[11].selected = true;
				}else{
					document.getElementById("year").options[dt.getYear()+1900-2012].selected = true;
					document.getElementById("month").options[dt.getMonth()-1].selected = true;
				}
			}else{
				document.getElementById("year").options[parseInt(y)-2012].selected = true;
				document.getElementById("month").options[parseInt(m)-1].selected = true;
			}
		}catch(e){
			alert(e);
		}
	}
	function submitFm(){
		try{
			document.getElementById("searchForm").year.value=document.getElementById("year").value;
			document.getElementById("searchForm").month.value=document.getElementById("month").value;;
			document.getElementById("searchForm").ks_name.value="JJJJDDYYYKKK";
			document.getElementById("searchForm").submit();
		}catch(e){
			alert(e);
		}
		
	}
</script>
</body>
</html>